<?php require_once 'header.php';?>    
<!-- DataTables Responsive CSS -->
    <link href="sb2/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">
        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            {{$_ctitle}}
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <thead>
                                    <tr>
                                        <th>姓名</th>
                                        <th>照片</th>
                                        <th>手机</th>
                                        <th>性别</th>
                                        <th>民族</th>
                                        <th>身份证</th>
                                        <th>家庭住址</th>
                                        <th>政治面貌</th>
                                        <th>家长</th>
                                        <th>家长电话</th>
                                        <th>班级</th>
                                        <th>学号</th>
                                        <th>寝室</th>
                                        <th>职务</th>
                                        <th>备注</th>
                                    </tr>
                                </thead>
                                <tbody>
                                	<?php
                                	$i=0;
                                	foreach ($result as $row){$i++;
                                	?>
                                    <tr class="<?php echo $i%2==0?"even":"odd";?> gradeA" id='<?php echo $row['id'];?>'>
                                    	<td><?php echo $row['sname'];?></td>
                                    	<td><img src="uploader/img/<?php echo $row['photo'];?>" width=60px height=75px></td>
                                        <td><?php echo $row['shouji'];?><br><a href="tel:<?php echo $row['shouji'];?>"><span class="glyphicon glyphicon-earphone"></span></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="sms:<?php echo $row['shouji'];?>"><span class="glyphicon glyphicon-envelope"></span></a><?php echo $qxrow['upd']==1?"&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:append(".$row['id'].")'><span class='glyphicon glyphicon-list-alt'></span></a>":"" ?> </td>
                                        <td><?php echo $row['xingbie'];?></td>
                                        <td><?php echo $row['minzu'];?></td>
                                        <td><?php echo $row['idcard'];?></td>
                                        <td><?php echo $row['home'];?></td>
                                        <td><?php echo $row['zhengzhi'];?></td>
                                        <td><?php echo $row['jiazhang'];?></td>
                                        <td><a href="tel:<?php echo $row['shouji'];?>"><?php echo $row['jzshouji'];?></a></td>
                                        <td><?php echo xdb::getInstance()->getvar("select cname from classes where cno=".$row['cno']);?></td>
                                        <td><?php echo $row['sno'];?></td>
                                        <td><?php echo $row['dorm'];?></td>
                                        <td><?php echo $row['zhiwu'];?></td>
                                        <td><?php echo $row['beizhu'];?></td>
                                    	<?php echo $qxrow['del']==1?"<td><a href='javascript:del(".$row['id'].")' class='glyphicon glyphicon-minus-sign' role='menuitem' tabindex='-1' style='color:red;'></a></td>":""?>
                                    </tr>
                                	<?php 
                                	}
                                	?>
                                </tbody>
                            </table>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
             </div>
        </div>
        <!-- /#page-wrapper -->
  <div class="modal fade" id="m">
  	<div class="modal-dialog" style="width:350px;">
  		<div class="modal-content">
  			<div class="modal-header">
  				<h4 class="modal-title btn-success">添加学生信息</h4>
  			</div>
  			<form  id="form">
  			<div class="modal-body">
  					<fieldset>
  						<div class="form-group">
  							<label>姓名</label>
  							<input type="text" id="content" name="content" class="form-control" placeholder="内容限定200字" required>
  						</div>
  						<div class="form-group">
  							<label>身份证</label>
  							<input type="text" id="btime" name="btime" class="form-control" placeholder="点击获取" required readonly >
  						</div>
  						<div class="form-group">
  							<label>事件等级</label>
  							<div>
  								<label><input type="radio" value="0" name="level" id="level0">0完成</label>&nbsp;
  								<label><input type="radio" value="1" name="level" id="level1" checked>1普通</label>&nbsp;
  								<label><input type="radio" value="2" name="level" id="level2">2重要</label>&nbsp;
  								<label><input type="radio" value="3" name="level" id="level3" >3紧急</label>
  							</div>
  						</div>
  					</fieldset>
  			</div>
  			<div class="modal-footer" >
  				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
  				<button type="submit" class="btn btn-primary">保存</button>
  			</div>
  			</form>
  		</div>
  	</div>
  </div>
  
  <div class="modal fade" id="m1">
  	<div class="modal-dialog" style="width:350px;">
  		<div class="modal-content">
  			<div class="modal-header">
  				<h4 class="modal-title btn-success">添加学生事务</h4>
  			</div>
  			<form  id="form1">
  			<div class="modal-body">
  					<fieldset>
  						<div class="form-group">
  							<label>姓名</label>
  							<input type="text" id="rname1" name="rname1" class="form-control" required readonly >
  						</div>
  						<div class="form-group">
  							<label>事件内容</label>
  							<input type="text" id="content1" name="content1" class="form-control" placeholder="内容限定200字" required>
  						</div>
  						<div class="form-group">
  							<label>截止日期</label>
  							<input type="text" id="btime1" name="btime1" class="form-control" placeholder="点击获取" required readonly >
  						</div>
  						<div class="form-group">
  							<label>事件类型</label>
  							<div>
  								<label><input type="radio" value="考勤" name="level1" id="level0" checked>考勤</label>&nbsp;
  								<label><input type="radio" value="奖励" name="level1" id="level1">奖励</label>&nbsp;
  								<label><input type="radio" value="处罚" name="level1" id="level2">处罚</label>&nbsp;
  								<label><input type="radio" value="安全与健康" name="level1" id="level3" >安全与健康</label>&nbsp;
  								<label><input type="radio" value="其他" name="level1" id="level4">其他</label>&nbsp;
  							</div>
  						</div>
  					</fieldset>
  			</div>
  			<div class="modal-footer" >
  				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
  				<button type="submit" class="btn btn-primary">保存</button>
  				<input type="hidden" name="id" id="id" value="">
  			</div>
  			</form>
  		</div>
  	</div>
  </div>
        <!-- DataTables JavaScript -->
<?php require_once 'bottom.php';?>
    <script src="sb2/vendor/datatables/js/jquery.dataTables.js"></script>
    <script src="sb2/vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
    <script src="sb2/vendor/datatables-responsive/dataTables.responsive.js"></script>
    <script>
    $(document).ready(function() {
    	$("#content1").click(function(){$(this).xautocomplete($.gc('stuevent'));});
        $("#btime1").click(function(){$(this).xrili();});
        $('#dataTables-example').DataTable({
            responsive: true,
            "aaSorting": [[ 0, "desc" ]]
        });
        var options = {
                type: 'post',
                data:{'type':'ins'},
    		    url:	$.gu("toDoPrivate"),
    		    beforeSubmit:function(){
    		    	if($("#content").val().length==0||$("#btime").val().length<10||$("#content").val().length>200){
    		    		$.xalert("请正确填写信息！");
    		    		return false;
    		    	}
    		    	$.xloading(1);
    		    },
    		    success: function(data) {
    		    	$.xloading(0);
    		    	if(data==0){
    			    	$.xalert('该事件已存在，无需再添加！');
    		    	}else if(data==1){
    		    		window.location.reload();
    		    	}else{
    		    		alert(data);
    		    	}
    		    } };
    	$('#form').ajaxForm(options);

    	var options1 = {
    			type: 'post',
                data:{'type':'insFromSchoolRoll'},
    		    url:	$.gu("stuEventManager"),
    		    beforeSubmit:function(){
    		    	if($("#content1").val().length==0||$("#btime1").val().length<10||$("#content1").val().length>250){
    		    		$.xalert("请正确填写信息，内容200字内！");
    		    		return false;
    		    	}
    		    	$.xloading(1);
    		    },
    		    success: function(data) {
    		    	$.xloading(0);
    		    	if(data==0){
    			    	$.xalert('添加失败，事务已存在！');
    		    	}else if(data==1){
    		    		$.xalert('添加成功！');
    		    	}else{
    		    		$.xalert(data);
    		    	}
    		    } };
    	$('#form1').ajaxForm(options1);
    });
    function append(id){
    	$("#form1").resetForm();
    	$("#m1").modal({backdrop:"static",keyboard:false,show:true}).on("hide.bs.modal",function(){$("#form").resetForm();});
    	$("#id").val(id);
    	$("#rname1").val($("#"+id+" td:eq(0)").text());
    }
    function update(id){
    	$("#form1").resetForm();
    	$("#m1").modal({backdrop:"static",keyboard:false,show:true});
    	$("#id").val(id);
    	$("#content1").val($("#"+id+" td:eq(1)").text());
    	$("#btime1").val($("#"+id+" td:eq(2)").text());
    	$("input[name='level1'][value='"+$("#"+id+" td:eq(4)").text()+"']").attr("checked",true); 
    }
    function del(id){
		$.xconfirm("删除后无法恢复，确定要删除此条记录么？",function(data){
 			if(data){
				$.xloading(1);
				$.post($.gu("schoolRollManager"),{type:'del',id:id},function(data1){
					if(data1==0){
						$.xloading(0);
						$.xalert("删除失败");
					}else{
						window.location.reload();
					}
				}); 
			} 
		});
    }
    </script>